// pages/web/web.js
const app = getApp()
var host = app.globalData.host;
var self = null;

Page({
  data: {
    themeColor: '',
    url: '',
    itemId: '',
    shareTitle: '',
    shareImage: ''
  },
  onLoad: function (options) {
    self = this;
    self.getStyle();
    self.setData({
      url: options.url,
      itemId: options.itemId ? options.itemId : '',
      shareTitle: options.shareTitle ? options.shareTitle : '',
      shareImage: options.shareImage ? options.shareImage : ''
    })
  },
  getStyle() {
    self.setData({
      themeColor: app.globalData.themeColor
    })
  },
  onShareAppMessage(object) {
    if (self.data.itemId) {
      return {
        title: self.data.shareTitle,
        imageUrl: self.data.shareImage,
        path: "/pages/productInfo/productInfo?itemId=" + self.data.itemId
      }
    } else {
      return {
        title: "有趣Befun",
        imageUrl: "",
        path: "/pages/web/web?url=" + object.webViewUrl
      }
    }
  }
})